/******************************************************************************
//             INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright (c) 2000-2001 Intel Corporation. All Rights Reserved.
//
//  Description:
//      Intel(R) JPEG library for X platform 
//
********************************************************************************/
#include "_ijx.h"

/******************************************************************************
// Name:             ijxCopyExpand_8u_C1
// Description:      Copy 8-bit image data and expand its boundary pixels.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//          srcStep: Specifies the number of bytes in a line of the image. 
//          srcSize: Identifies IppiSize data structure to indicate the size of 
//                   source rectangle.
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//          dstSize: Identifies IppiSize data structure to indicate the size of 
//                   destination rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopyExpand_8u_C1 (const Ipp8u *pSrc, 
                          int srcStep,
                          IppiSize srcSize,
                          Ipp8u *pDst,
                          int dstStep,
                          IppiSize dstSize)
{
    int x, y;
    Ipp8u a; 
    const Ipp8u *pSrcData;
    Ipp8u *pDstData;

    for (y=0; y<srcSize.height; y++) {
        pSrcData=pSrc;
        pDstData=pDst;
        for (x=0; x<srcSize.width; x++) {
            *pDstData++=*pSrcData++;
        }
        a=pDstData[-1];

        /* Extend boundary in a horizontal */
        for (; x<dstSize.width; x++) {
            *pDstData++=a;
        }

        pSrc+=srcStep;
        pDst+=dstStep;
    }

    pSrcData=pDst-dstStep;

    /* Pading vertical lines*/
    for (; y<dstSize.height; y++) {
        for(x=0; x<dstStep; x++){
            pDst[x]=pSrcData[x];
        }
        pDst+=dstStep;
    }

}

/******************************************************************************
// Name:             ijxCopyExpand_16u_C1
// Description:      Copy image data and expand its boundary pixels.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//          srcStep: Specifies the number of bytes in a line of the image. 
//          srcSize: Identifies IppiSize data structure to indicate the size of 
//                   source rectangle.
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//          dstSize: Identifies IppiSize data structure to indicate the size of 
//                   destination rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopyExpand_16u_C1 (const Ipp8u *pSrc, 
                            int srcStep,
                            IppiSize srcSize,
                            Ipp8u *pDst,
                            int dstStep,
                            IppiSize dstSize)
{
    int x, y;
    Ipp16u a; 
    const Ipp16u *pSrcData;
    Ipp16u *pDstData;

    for (y=0; y<srcSize.height; y++) {
        pSrcData=(Ipp16u *)pSrc;
        pDstData=(Ipp16u *)pDst;
        for (x=0; x<srcSize.width; x++) {
            *pDstData++=*pSrcData++;
        }
        a=pDstData[-1];

        /* Extend boundary in a horizontal */
        for (; x<dstSize.width; x++) {
            *pDstData++=a;
        }

        pSrc+=srcStep;
        pDst+=dstStep;
    }

    pSrcData=(Ipp16u *)(pDst-dstStep);
    pDstData=(Ipp16u *)pDst;
    dstStep =dstStep>>1;

    /* Pading vertical lines*/
    for (; y<dstSize.height; y++) {
        for(x=0; x<dstStep; x++){
            pDstData[x]=pSrcData[x];
        }
        pDstData+=dstStep;
    }

}

/******************************************************************************
// Name:             ijxCopyExpand_8u_C3
// Description:      Copy 8-bit image data and expand its boundary pixels.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//                   The source buffer can support down-top storage format.   
//          srcStep: Specifies the number of bytes in a line of the image. 
//          srcSize: Identifies IppiSize data structure to indicate the size of 
//                   source rectangle.
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//          dstSize: Identifies IppiSize data structure to indicate the size of 
//                   destination rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                   The destination buffer just support top-down storage format.
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopyExpand_8u_C3 (const Ipp8u *pSrc, 
                           int srcStep,
                           IppiSize srcSize,
                           Ipp8u *pDst,
                           int dstStep,
                           IppiSize dstSize)
{
    int x, y;
    Ipp8u a,b,c; 
    const Ipp8u *pSrcData;
    Ipp8u *pDstData;

    for (y=0; y<srcSize.height; y++) {
        pSrcData=pSrc;
        pDstData=pDst;
        for (x=0; x<srcSize.width; x++) {
            *pDstData++=*pSrcData++;
            *pDstData++=*pSrcData++;
            *pDstData++=*pSrcData++;
        }
        a=pSrcData[-3], b=pSrcData[-2], c=pSrcData[-1];

        /* Extend boundary in a horizontal */
        for (; x<dstSize.width; x++) {
            *pDstData++=a;
            *pDstData++=b;
            *pDstData++=c;
        }

        pSrc+=srcStep;
        pDst+=dstStep;
    }

    pSrcData=pDst-dstStep;

    /* Pading vertical lines*/
    for (; y<dstSize.height; y++) {
        for(x=0; x<dstStep; x++){
            pDst[x]=pSrcData[x];
        }
        pDst+=dstStep;
    }

}

/******************************************************************************
// Name:             ijxCopy_8u_C1R
// Description:      Copy 8-bit image data.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//                   The source buffer just support top-down storage format.
//          srcStep: Specifies the number of bytes in a line of the image. 
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//         pROISize: Identifies IppiSize data structure to indicate the size of 
//                   copied rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                   The destination buffer can support down-top storage format.   
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopy_8u_C1R (const Ipp8u *pSrc, 
                      int srcStep,
                      Ipp8u *pDst,
                      int dstStep,
                      IppiSize roiSize)
{
    int x, y;
    int nLineLen;

    nLineLen=roiSize.width;

    if (0<nLineLen) {
        for (y=0; y<roiSize.height; y++) {
            for(x=0; x<nLineLen; x++){
                pDst[x]=pSrc[x];
            }
            pSrc+=srcStep;
            pDst+=dstStep;
        }
    }
}

/******************************************************************************
// Name:             ijxCopy_16u_C1R
// Description:      Copy image data.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//                   The source buffer just support top-down storage format.
//          srcStep: Specifies the number of bytes in a line of the image. 
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//          roiSize: Identifies IppiSize data structure to indicate the size of 
//                   copied rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                   The destination buffer can support down-top storage format.   
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopy_16u_C1R (const Ipp8u *pSrc, 
                       int srcStep,
                       Ipp8u *pDst,
                       int dstStep,
                       IppiSize roiSize)
{
    int x, y;
    int nLineLen;
    Ipp16u *pSrcData;
    Ipp16u *pDstData;
     

    nLineLen=roiSize.width;

    pSrcData=(Ipp16u *)pSrc;
    pDstData=(Ipp16u *)pDst;
    srcStep=srcStep>>1;
    dstStep=dstStep>>1;

    if (0<nLineLen) {
        for (y=0; y<roiSize.height; y++) {
            for(x=0; x<nLineLen; x++){
                pDstData[x]=pSrcData[x];
            }
            pSrcData+=srcStep;
            pDstData+=dstStep;
        }
    }

}

/******************************************************************************
// Name:             ijxCopy_8u_C3R
// Description:      Copy 8-bit image data.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//          srcStep: Specifies the number of bytes in a line of the image. 
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//          roiSize: Identifies IppiSize data structure to indicate the size of 
//                   copied rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopy_8u_C3R (const Ipp8u *pSrc, 
                      int srcStep,
                      Ipp8u *pDst,
                      int dstStep,
                      IppiSize roiSize)
{
    int x, y;
    int nLineLen = roiSize.width*3;

    for (y=0; y<roiSize.height; y++) {
        for(x=0; x<nLineLen; x++){
            pDst[x]=pSrc[x];
        }
        pSrc+=srcStep;
        pDst+=dstStep;
    }

}

/******************************************************************************
// Name:             ijxCopy_8u_C4R
// Description:      Copy 8-bit image data.
// Input Arguments: 
//             pSrc: Identifies the start address of the current image data. 
//          srcStep: Specifies the number of bytes in a line of the image. 
//          dstStep: Specifies the number of bytes in a line of destination buffer.
//          roiSize: Identifies IppiSize data structure to indicate the size of 
//                   copied rectangle.
//
// Output Arguments:
//             pDst: Identifies output image data buffer.
//                  
// Remarks:      
//                   pSrc!=pDst. 
//                   pSrc and pDst supports both of top-down and down top storage format.
//                   in this case, srcStep and dstStep can be less than 0;
//
******************************************************************************/
void ijxCopy_8u_C4R (const Ipp8u *pSrc, 
                      int srcStep,
                      Ipp8u *pDst,
                      int dstStep,
                      IppiSize roiSize)
{
    int x, y;
    int nLineLen = roiSize.width*4;

    for (y=0; y<roiSize.height; y++) {
        for(x=0; x<nLineLen; x++){
            pDst[x]=pSrc[x];
        }
        pSrc+=srcStep;
        pDst+=dstStep;
    }

}
/* EOF */

